﻿//**********this is window function for service due********************/

function serviceDueWindow(sssid, trackername, odometers, lastservicedue) {
    var txtjourney = createNewParamNumberField(_TrackerMain_JouneryKM, 8);
    txtjourney.setReadOnly(true);
    txtjourney.setValue(odometers);
    var txtservicedue = createNewParamNumberField(_TrackerMain_ServiceDue, 8);
    txtservicedue.setValue(lastservicedue);
    var win = new Ext.Window({
        title: trackername,
        layout: 'form',
        height: 180,
        width: 400,
        bodyStyle: 'padding-top:10px',
        //iconCls: 'report-alarm',
        items: [txtjourney, txtservicedue],
        minimizable: true,
        listeners: {
            'minimize': function() {
                addTaskButtonForWindow(win);
            }
        },
        buttons: [{ text: _NewForText_Confirm,
            handler: function() {
                Ext.Ajax.request({
                    url: 'HandlerChangeServiceDue',
                    method: 'post',
                    params: {
                        sssid: sssid,
                        servicedue: txtservicedue.getValue()
                    },
                    success: function(r) {
                        var val = r.responseText;
                        if (val == 0) {
                            msgUpdateSuccess();
                            devicestore.each(function(record) {
                                if (record.get("sssid") == sssid) {
                                    record.set("servicedue", txtservicedue.getValue());
                                }
                            });
                        }
                        else {
                            msgUpdateFailure();
                        }

                    }
                });
            }
}]
        });

    return win;
}